package cn.iune.web.erp.controllers;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import cn.iune.config.SecurityService;
import cn.iune.erp.accounting.IAccountCaptionService;
import cn.iune.erp.accounting.IAccountVoucherService;
import cn.iune.erp.accounting.IAccountYearService;
import cn.iune.erp.accounting.IAccountingService;
import cn.iune.erp.accounting.IPeriodCaptionService;
import cn.iune.erp.accounting.ISheetBalanceService;
import cn.iune.erp.setting.IParamSettingService;

/*
 * 会计总账模块
 */

@Controller
@RequestMapping(value="/accounting")
public class AccountingController {
	
	@Autowired
	private IAccountCaptionService accountCaptionService;
	
	@Autowired
	private ISheetBalanceService sheetBalanceService;
	
	@Autowired
	private IAccountVoucherService accountVoucherService;
	@Autowired
	private IAccountingService accountingService;
	@Autowired
	private IPeriodCaptionService periodCaptionService;
	
	@Autowired
	private IParamSettingService configureService;
	
	
	@Autowired
	private IAccountYearService accountYearService;
	
	@RequestMapping(value="/accountYear/single",method=RequestMethod.GET)
	public ModelAndView accountYearSingle(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountYear/single");
		mav.addObject("path","/accounting/accountYear/single");
		return mav;
	}
	
	@RequestMapping(value={
			"/accountYear/single/query"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountYearQuery(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return accountYearService.queryData(data);
	}

	@RequestMapping(value={
			"/accountYear/single/save"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountYearSave(@RequestBody JSONObject object) {
		return accountYearService.saveData(object);
	}

	@RequestMapping(value={
			"/accountYear/single/delete"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountYearDelete(@RequestBody JSONObject data) {
		return accountYearService.deleteData(data);
	}

	@RequestMapping(value={
			"/accountYear/single/create"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountYearCreate(@RequestBody JSONObject data, HttpServletRequest request) {
		data = SecurityService.translateFun(data);
		JSONObject json = accountYearService.newData(data);
		return json;
	}


	@RequestMapping(value={
			"/accountYear/single/createDetail"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountYearSaveDetail(@RequestBody JSONObject data) {
		return accountYearService.newDataDetail(data);
	}

	@RequestMapping(value={
			"/accountYear/single/queryDetail"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountYearQueryDetail(@RequestBody JSONObject data) {
		return accountYearService.queryDataDetail(data);
	}


	
	
	
	
	@RequestMapping(value="/accountCaption/tree",method=RequestMethod.GET)
	public ModelAndView accountCaptionTree(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountCaption/tree");
		return mav;
	}

	@RequestMapping(value="/accountCaption/selectSingle",method=RequestMethod.GET)
	public ModelAndView accountCaptionSelectSingle(){
	
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountCaption/selectSingle");
		return mav;
	}
	
	@RequestMapping(value="/accountCaption/sortView",method=RequestMethod.GET)
	public ModelAndView accountCaptionSortView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountCaption/sort");
		return mav;
	}
	//重新排序
	@RequestMapping(value = "/accountCaption/sort", method = RequestMethod.POST)
	@ResponseBody
	public void accountCaptionSort(@RequestBody JSONObject data){
		String parentID = data.getString("parentID");
		JSONArray jsonArray =  data.getJSONArray("ids");
//		System.out.println("jsonArray-->"+jsonArray);
		List<String> ids = new ArrayList<String>();
		for(int i=0; i<jsonArray.size();i++){
			ids.add(jsonArray.getString(i));
		}
//		System.out.println("ids-->"+ids);
		accountCaptionService.sort(parentID, ids);
	}
	
	
	@RequestMapping(value="/accountCaption/moveView",method=RequestMethod.GET)
	public ModelAndView accountCaptionMoveView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountCaption/move");
		return mav;
	}
	//移动
	@RequestMapping(value = "/accountCaption/move", method = RequestMethod.POST)
	@ResponseBody
	public void accountCaptionMove(@RequestBody JSONObject data){
		String rowID = data.getString("rowID");
		String oldParentID = data.getString("oldParentID");
		String newParentID = data.getString("newParentID");
		System.out.println("rowID-->"+rowID);
		System.out.println("oldParentID-->"+oldParentID);
		System.out.println("newParentID-->"+newParentID);
		accountCaptionService.move(rowID, oldParentID, newParentID);
	}
	
	
	
	@RequestMapping(value={"/accountCaption/tree/create"},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountCaptionCreate(@RequestBody JSONObject data) {
		data = SecurityService.translateFun(data);
		JSONObject json = accountCaptionService.newData(data);
		return json;
	}

	@RequestMapping(value="/accountCaption/tree/query",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountCaptionQuery(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return accountCaptionService.queryData(data);
	}

	@RequestMapping(value="/accountCaption/tree/save",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountCaptionSave(@RequestBody JSONObject object) {
		return accountCaptionService.saveData(object);
	}
	
	@RequestMapping(value="/accountCaption/tree/delete",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountCaptionDelete(@RequestBody JSONObject data) {
		return accountCaptionService.deleteData(data);
	}
	
	
	
	//科目余额
	@RequestMapping(value="/accountCaptionQuery/list",method=RequestMethod.GET)
	public ModelAndView accountCaptionQuery(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountCaptionQuery/list");
		return mav;
	}

	
	
	
	
	//会计凭证
	@RequestMapping(value="/accountVoucher/single",method=RequestMethod.GET)
	public ModelAndView accountVoucherSingle(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/accountVoucher/single");
		mav.addObject("path","/accounting/accountVoucher/single");
		return mav;
	}
	
	
	@RequestMapping(value={
			"/accountVoucher/single/query",
			"/draftVoucher/single/query"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountVoucherQuery(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return accountVoucherService.queryData(data);
	}

	@RequestMapping(value={
			"/accountVoucher/single/save",
			"/draftVoucher/single/save"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountVoucherSave(@RequestBody JSONObject object) {
		return accountVoucherService.saveData(object);
	}

	@RequestMapping(value={
			"/accountVoucher/single/delete",
			"/draftVoucher/single/delete"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountVoucherDelete(@RequestBody JSONObject data) {
		return accountVoucherService.deleteData(data);
	}

	@RequestMapping(value={
			"/accountVoucher/single/create",
			"/draftVoucher/single/create"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountVoucherCreate(@RequestBody JSONObject data, HttpServletRequest request) {
		data = SecurityService.translateFun(data);
		JSONObject json = accountVoucherService.newData(data);
		return json;
	}


	@RequestMapping(value={
			"/accountVoucher/single/createDetail",
			"/draftVoucher/single/createDetail"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountVoucherSaveDetail(@RequestBody JSONObject data) {
		return accountVoucherService.newDataDetail(data);
	}

	@RequestMapping(value={
			"/accountVoucher/single/queryDetail",
			"/draftVoucher/single/queryDetail"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject accountVoucherQueryDetail(@RequestBody JSONObject data) {
		return accountVoucherService.queryDataDetail(data);
	}

	

	//分录底稿
	@RequestMapping(value="/draftVoucher/single",method=RequestMethod.GET)
	public ModelAndView draftVoucherSingle(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/draftVoucher/single");
		mav.addObject("path","/accounting/draftVoucher/single");
		return mav;
	}
	
	//由分录底稿生成会计凭证
	@RequestMapping(value = {"/draftVoucher/single/formalKJPZ"}, method = RequestMethod.POST)
	@ResponseBody
	public JSONObject formalKJPZ(@RequestBody JSONObject params, HttpServletRequest request){
		String id = params.getString("rowID");
		
		String cUsercode = SecurityService.getCurrentPerson().getString("cUsercode");
		String cUsername = SecurityService.getCurrentPerson().getString("cUsername");
		String userId = SecurityService.getCurrentPerson().getString("userId");
		
		return accountingService.formalKJPZ(id, cUsercode, cUsername, userId);
	}

	
	//////////////////////////////////////////////////////////////////////////////////////
	@RequestMapping(value={
			"/accountVoucher/single/confirm"
			},method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> accountVoucherConfirm(@RequestBody JSONObject data) {
		String id = data.getString("id");
		
		String tUsercode = SecurityService.getCurrentPerson().getString("cUsercode");
		String tUsername = SecurityService.getCurrentPerson().getString("cUsername");
		String userId = SecurityService.getCurrentPerson().getString("userId");
		
		String employeeNo = SecurityService.getCurrentPsm().getsFID();
		String employeeName = SecurityService.getCurrentPsm().getsFName();
		
		return accountingService.accountVoucherConfirm(id,tUsercode,tUsername,userId,employeeNo,employeeName);
	}

	@RequestMapping(value={
			"/accountVoucher/single/active"
			},method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> accountVoucherActive(@RequestBody JSONObject data) {
		String id = data.getString("id");
		return accountingService.accountVoucherActive(id);
	}
	@RequestMapping(value={
			"/accountVoucher/single/agreeIt"
			},method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> accountVoucherAgreeIt(@RequestBody JSONObject data) {
		String id = data.getString("id");
		
		String tUsercode = SecurityService.getCurrentPerson().getString("cUsercode");
		String tUsername = SecurityService.getCurrentPerson().getString("cUsername");
		String userId = SecurityService.getCurrentPerson().getString("userId");
		
		String employeeNo = SecurityService.getCurrentPsm().getsFID();
		String employeeName = SecurityService.getCurrentPsm().getsFName();
		
		return accountingService.accountVoucherAgreeIt(id,tUsercode,tUsername,userId,employeeNo,employeeName);
	}

	@RequestMapping(value={
			"/accountVoucher/single/unAgree"
			},method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> accountVoucherUnAgree(@RequestBody JSONObject data) {
		String id = data.getString("id");
		return accountingService.accountVoucherUnAgree(id);
	}
	
	@RequestMapping(value={
			"/accountVoucher/single/close"
			},method=RequestMethod.POST)
	@ResponseBody
	public void accountVoucherClose(@RequestBody JSONObject data) {
		String id = data.getString("id");
		accountingService.accountVoucherClose(id);
	}

	@RequestMapping(value={
			"/accountVoucher/single/open"
			},method=RequestMethod.POST)
	@ResponseBody
	public void accountVoucherOpen(@RequestBody JSONObject data) {
		String id = data.getString("id");
		accountingService.accountVoucherOpen(id);
	}

//	@RequestMapping(value={
//			"/accountVoucher/single/printPDF"
//			},method=RequestMethod.GET)
//	@ResponseBody
//	public void accountVoucherPrintPDF(@RequestParam(value="id",required=true) String id, HttpServletRequest request, HttpServletResponse response) throws Exception {
//		accountingService.accountVoucherPrintPDF(id, response);
//	}
	
	//会计凭证过账/撤回
	@RequestMapping(value={"/accountVoucher/single/posting"},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject posting(@RequestBody JSONObject data) {
		String voucherNo = data.getString("voucherNo");
		String enterpriseNo = data.getString("enterpriseNo");
		System.out.println("voucherNo-->>"+voucherNo);
		System.out.println("enterpriseNo-->>"+enterpriseNo);
		
		String tUsercode = SecurityService.getCurrentPerson().getString("cUsercode");
		String tUsername = SecurityService.getCurrentPerson().getString("cUsername");
		String userId = SecurityService.getCurrentPerson().getString("userId");
		return accountingService.bookkeeping(voucherNo, tUsercode, tUsername, userId, enterpriseNo);
	}

	
	
	
	//期初开账
	@RequestMapping(value="/periodCaption/initial",method=RequestMethod.GET)
	public ModelAndView periodCaptionInitial(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/periodCaption/initial");
		return mav;
	}
	
	//期初开账
	@RequestMapping(value="/periodCaption/calculate/initial",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionInitial(@RequestBody JSONObject data) {
		String yearPeriodNo = data.getString("yearPeriodNo");
//		String yearNo = yearPeriodNo.substring(0, 3);
//		String periodNo = yearPeriodNo.substring(5,6);
		String yearNo = yearPeriodNo.split("-")[0];
		String periodNo = yearPeriodNo.split("-")[1];
		String userId = SecurityService.getCurrentPerson().getString("userId");
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return accountingService.accountingInitial(yearNo, periodNo, userId, enterpriseNo);
	}
	
	@RequestMapping(value={"/periodCaption/list/save"},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionSave(@RequestBody JSONObject data) {
		return periodCaptionService.saveData(data);
	}
	
	//删除会计期初开账数据的数据库记录。之后重新开账
	@RequestMapping(value="/periodCaption/calculate/delete",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionDelete(@RequestBody JSONObject data) {
		String yearPeriodNo = data.getString("yearPeriodNo");
//		String yearNo = yearPeriodNo.substring(0, 3);
//		String periodNo = yearPeriodNo.substring(5,6);
		String yearNo = yearPeriodNo.split("-")[0];
		String periodNo = yearPeriodNo.split("-")[1];
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return accountingService.accountingDelete(yearNo, periodNo, enterpriseNo);
	}
	
	//期初开账结束
	@RequestMapping(value="/periodCaption/calculate/initSubmit",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionInitSubmit(@RequestBody JSONObject data) {
		String yearPeriodNo = data.getString("yearPeriodNo");
//		String yearNo = yearPeriodNo.substring(0, 3);
//		String periodNo = yearPeriodNo.substring(5,6);
		String yearNo = yearPeriodNo.split("-")[0];
		String periodNo = yearPeriodNo.split("-")[1];
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return accountingService.accountingInitSubmit(yearNo, periodNo, enterpriseNo);
	}
	
	//期初开账结束后试算平衡弹出窗口
	@RequestMapping(value="/periodCaption/trialpop",method=RequestMethod.GET)
	public ModelAndView periodCaptionTrialpop(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/periodCaption/trialpop");
		return mav;
	}
	
	//期初开账结束后试算平衡
	@RequestMapping(value="/periodCaption/calculate/initTrial",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionInitTrial(@RequestBody JSONObject data) {
		String yearPeriodNo = data.getString("yearPeriodNo");
//		String yearNo = yearPeriodNo.substring(0, 3);
//		String periodNo = yearPeriodNo.substring(5,6);
		String yearNo = yearPeriodNo.split("-")[0];
		String periodNo = yearPeriodNo.split("-")[1];
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return periodCaptionService.initTrial(yearNo, periodNo, enterpriseNo);
	}
	
	//取消开账结束
	@RequestMapping(value="/periodCaption/calculate/initActive",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionInitActive(@RequestBody JSONObject data) {
		String yearPeriodNo = data.getString("yearPeriodNo");
//		String yearNo = yearPeriodNo.substring(0, 3);
//		String periodNo = yearPeriodNo.substring(5,6);
		String yearNo = yearPeriodNo.split("-")[0];
		String periodNo = yearPeriodNo.split("-")[1];
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return accountingService.accountingInitActive(yearNo, periodNo, enterpriseNo);
	}

	
	
	
	
	//资产负债表模板
	@RequestMapping(value="/sheetBalance/template",method=RequestMethod.GET)
	public ModelAndView sheetBalanceTemplate(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetBalance/template");
		return mav;
	}
	
	//重新排序
	@RequestMapping(value="/sheetBalance/sortView",method=RequestMethod.GET)
	public ModelAndView sheetBalanceSortView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetBalance/sort");
		return mav;
	}
	
	//重新排序
	@RequestMapping(value = {
			"/sheetBalance/sort",
			"/sheetProfit/sort",
			"/sheetCashflow/sort"
			}, method = RequestMethod.POST)
	@ResponseBody
	public void sheetBalanceSort(@RequestBody JSONObject data){
		String parentID = data.getString("parentID");
		JSONArray jsonArray =  data.getJSONArray("ids");
		List<String> ids = new ArrayList<String>();
		for(int i=0; i<jsonArray.size();i++){
			ids.add(jsonArray.getString(i));
		}
		sheetBalanceService.sort(parentID, ids);
	}
	
	//资产负债表模板
	@RequestMapping(value={
			"/sheetBalance/template/create",
			"/sheetProfit/template/create",
			"/sheetCashflow/template/create"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject sheetBalanceCreate(@RequestBody JSONObject data) {
		data = SecurityService.translateFun(data);
		JSONObject json = sheetBalanceService.newData(data);
		return json;
	}

	@RequestMapping(value= {
			"/sheetBalance/template/query",
			"/sheetProfit/template/query",
			"/sheetCashflow/template/query"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject sheetBalanceQuery(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return sheetBalanceService.queryData(data);
	}

	@RequestMapping(value= {
			"/sheetBalance/template/save",
			"/sheetProfit/template/save",
			"/sheetCashflow/template/save"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject sheetBalanceSave(@RequestBody JSONObject object) {
		return sheetBalanceService.saveData(object);
	}
	
	@RequestMapping(value= {
			"/sheetBalance/template/delete",
			"/sheetProfit/template/delete",
			"/sheetCashflow/template/delete"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject sheetBalanceDelete(@RequestBody JSONObject data) {
		return sheetBalanceService.deleteData(data);
	}
	
	//资产负债表
	@RequestMapping(value="/sheetBalance/show",method=RequestMethod.GET)
	public ModelAndView sheetBalanceShowView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetBalance/show");
		return mav;
	}

	//资产负债表
	@RequestMapping(value= {
			"/sheetBalance/show/query",
			"/sheetProfit/show/query",
			"/sheetCashflow/show/query"
			},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject sheetBalanceShow(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return sheetBalanceService.shownData(data);
	}
	
	
	//利润表模板
	@RequestMapping(value="/sheetProfit/template",method=RequestMethod.GET)
	public ModelAndView sheetProfitTemplate(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetProfit/template");
		return mav;
	}
	
	//重新排序
	@RequestMapping(value="/sheetProfit/sortView",method=RequestMethod.GET)
	public ModelAndView sheetProfitSortView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetProfit/sort");
		return mav;
	}
	
	//利润表
	@RequestMapping(value="/sheetProfit/show",method=RequestMethod.GET)
	public ModelAndView sheetProfitShowView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetProfit/show");
		return mav;
	}
	
	
	//现金流量表模板
	@RequestMapping(value="/sheetCashflow/template",method=RequestMethod.GET)
	public ModelAndView sheetCashflowTemplate(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetCashflow/template");
		return mav;
	}
	
	//重新排序
	@RequestMapping(value="/sheetCashflow/sortView",method=RequestMethod.GET)
	public ModelAndView sheetCashflowSortView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetCashflow/sort");
		return mav;
	}
	
	//现金流量表
	@RequestMapping(value="/sheetCashflow/show",method=RequestMethod.GET)
	public ModelAndView sheetCashflowShowView(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/sheetCashflow/show");
		return mav;
	}

	
	
	//期间损益设置
	@RequestMapping(value="/profitLoss/conf",method=RequestMethod.GET)
	public ModelAndView profitLossConf(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/profitLoss/conf");
		return mav;
	}
	
	//期间损益设置
	@RequestMapping(value="/profitLoss/list/query",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject profitLossQuery(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return accountCaptionService.queryData(data);
	}

	//期间损益设置
	@RequestMapping(value="/profitLoss/list/save",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject profitLossSave(@RequestBody JSONObject object) {
		return accountCaptionService.saveData(object);
	}

	
	//科目余额表
	@RequestMapping(value="/periodCaption/list",method=RequestMethod.GET)
	public ModelAndView periodCaptionList(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/periodCaption/list");
		return mav;
	}
	
	//科目余额表
	@RequestMapping(value={"/periodCaption/list/query"},method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionQuery(@RequestBody JSONObject data) {
		data = SecurityService.addDataAccessPerm(data);
		return periodCaptionService.queryData(data);
	}
	


	//获取会计现行年月
	@RequestMapping(value="/paramSetting/getInfo",method=RequestMethod.GET)
	@ResponseBody
	public JSONObject configureInfo() {
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return configureService.getJson(enterpriseNo);
	}
	
	//会计月结
	@RequestMapping(value="/periodCaption/next",method=RequestMethod.GET)
	public ModelAndView periodCaptionNext(){
		ModelAndView mav = new ModelAndView("/appcenter/accounting/periodCaption/next");
		return mav;
	}
	
	//会计月结
	@RequestMapping(value="/periodCaption/calculate/next",method=RequestMethod.POST)
	@ResponseBody
	public JSONObject periodCaptionNext(@RequestBody JSONObject data) {
		String yearPeriodNo = data.getString("yearPeriodNo");
//		String yearNo = yearPeriodNo.substring(0, 3);
//		String periodNo = yearPeriodNo.substring(5,6);
		String yearNo = yearPeriodNo.split("-")[0];
		String periodNo = yearPeriodNo.split("-")[1];
		String userId = SecurityService.getCurrentPerson().getString("userId");
		String enterpriseNo = SecurityService.getCurrentOgn().getsFID();
		return accountingService.accountingNext(yearNo, periodNo, userId, enterpriseNo);
	}

	
	

}
